//
//  ItemView.m
//  lianganyuchu
//
//  Created by iMac on 17/3/21.
//  Copyright © 2017年 杭州桑缇电子商务有限公司. All rights reserved.
//

#import "ItemView.h"
@interface ItemView()
{
    UILabel *m_labTitle;
    UILabel *m_labNum;
    UILabel *m_labPrice;
}
@end
@implementation ItemView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubviewsWith:frame];
    }
    return self;
}
-(void)addSubviewsWith:(CGRect)frame
{
    CGSize sizeBtn=frame.size;
    m_labTitle=[[UILabel alloc]initWithFrame:CGRectMake(kDistance, kDistance, 140, 20)];
    [m_labTitle setTextColor:TEXT_DEEP];
    [m_labTitle setFont:[UIFont LightFontOfSize:16]];
    [self addSubview:m_labTitle];
    
    
    m_labPrice=[[UILabel alloc]initWithFrame:CGRectMake(sizeBtn.width-kDistance-60, kDistance, 60, 20)];
    [m_labPrice setTextColor:TEXT_LIGHT];
    [m_labPrice setFont:[UIFont FontOfSize:15]];
    [m_labPrice setTextAlignment:NSTextAlignmentRight];
    [self addSubview:m_labPrice];
    
    m_labNum=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(m_labPrice.frame)-10-50, kDistance, 50, 20)];
    [m_labNum setTextColor:TEXT_MIDDLE];
    [m_labNum setFont:[UIFont FontOfSize:15]];
    [m_labNum setTextAlignment:NSTextAlignmentRight];
    [self addSubview:m_labNum];
}
-(void)bindWith:(ItemTable *)item
{
    [m_labTitle setText:item.name];
    [m_labPrice setText:[NSString stringWithFormat:@"￥%@",item.price]];
    [m_labNum setText:[NSString stringWithFormat:@"%@份",item.num]];
}

@end
